#ifndef SHAERD_FRAME_BUFFER_H
#define SHAERD_FRAME_BUFFER_H

#include <vector>
#include <mutex>

// 共享 buffer，之后可以作为基类方式，创建不同的共享缓冲区
class SharedFrameBuffer {
    public:
        void SetFrame(const std::vector<uint8_t>& frame) {
            std::lock_guard<std::mutex> lock(_mutex);
            _frame = frame;
        }
    
        bool GetFrame(std::vector<uint8_t>& out) {
            std::lock_guard<std::mutex> lock(_mutex);
            if (_frame.empty()) return false;
            out = _frame;
            return true;
        }
    
    private:
        std::vector<uint8_t> _frame;
        std::mutex _mutex;
    };
    

#endif /* SHAERD_FRAME_BUFFER_H */